package com.googlecode.garbagecan.asmstudy.helloworld;

import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;

public class HelloWorldClassAdapter extends ClassAdapter {
	
	public HelloWorldClassAdapter(ClassVisitor cv) {
		super(cv);
	}
	
	public MethodVisitor visitMethod(final int access, final String name,
		final String desc, final String signature, final String[] exceptions) {
		MethodVisitor mv = cv.visitMethod(access, name, desc, signature,exceptions);

		MethodVisitor wrappedMv = mv;
		if (mv != null) {
			if (name.equals("sayHello")) { 
				wrappedMv = new HelloWorldMethodAdapter(mv);
			}
		}
		return wrappedMv;
	}
}
